#!/usr/bin/python
#-*- coding: utf-8 -*-

from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
from OpenGL.arrays import vbo
from numpy import array
from collections import namedtuple
import sys
import math

WIDTH, HEIGHT = 500, 500


def display():
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glLoadIdentity()
    glTranslate(0., 0., -6.)
    glColor3f(0., 0., 1.)
    glutWireTeapot(1.0)
    glutSwapBuffers()
    

def initGL(w, h):
    glClearColor(1,1,1,1)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    gluPerspective(45., float(w)/h, 1., 100.)
    glMatrixMode(GL_MODELVIEW)
    
    
def main():
    
    # GLUT initialisieren
    glutInit(sys.argv) # kommandozeilenparameter uebergeben, glut library init
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) # Displaymodus fuer das Window
    glutInitWindowSize(WIDTH,HEIGHT)
    glutCreateWindow("Simple OpenGL Window")

    # Callback-Funktionen registrieren
    glutDisplayFunc(display)
    
   # Hack for Mac OS X
#   cwd = os.getcwd()
#   glutInit(sys.argv)
#   os.chdir(cwd)

    # OpenGL Kontext initialisieren
    initGL(WIDTH, HEIGHT)

    # Start GLUT Mainloop
    glutMainLoop()
    
    
    
if __name__ == '__main__':
    main()
